<keep-alive></keep-alive>
<template>

  <div class="" style="">

    <!--拍照-->
 
    <input type="file"   id="inputFileCamera" style="z-index:-999;opacity:0;" class="position-absolute"  v-on:change="getCameraOnchange($event)"  capture="camera"  accept="image/*">

    <!--相册-->

    <input type="file"   id="inputFileImage" style="z-index:-999;opacity:0;" class="position-absolute"   v-on:change="getCameraImgOnchange($event)"  accept="image/*" >


      <div class="home-bar page-bar position-fixed ">
        
       
        <mt-header title="">
         <mt-button @click="goback()"  slot="left" icon="back" style="font-size:18px">{{doctorName}}</mt-button>
       <!--<mt-button  slot="right">历史记录</mt-button>-->
      </mt-header>
      </div>
   
    <br>

        


    <div class="height-56"></div>



    
          <!--对话框-->
            <div class="position-relative "  style="min-height:50px;margin:2px 6px;" v-for="(item,index) in DialogBoxValArr">
                    
                    <div class="color-888888  text-align-center font-size-0-7rem" style="margin:4px 0;">{{item.createDate}}</div>
                    <div  style="width:100%;min-height:50px;">
                          <div  class="list-left" style="position-relative">
                            <div class="overflow-hidden" style="border-radius:50%;margin-top:4px;" v-bind:style="{height:DialogBoximgHeight+'px'}" >
                              <img  v-if="item.sendId!=user.id" class="width100" v-bind:src="doctorImg" :onerror="SpareImg()"  >
                            </div>  
                              <div v-if="item.sendId!=user.id" class="text-align-center color-888888 font-size-0-6rem">{{ConversationName!=''?(ConversationName.name).substr(ConversationName.name.length-2,ConversationName.name.length):(doctorVal.name).substr(doctorVal.name.length-2,doctorVal.name.length)}}</div>
                          </div>
                            <div class="font-size-13 display-inline-block position-relative word-break-normal"  style="width:76%;min-height:50px;">
                                  <div v-if="item.sendId!=user.id">
                                  <!--对方发的文字-->
                                    <div   v-if="item.type=='0'" class="word-wrap-break-word bg-ffffff  color-666666 border-radius-4" style="margin-left:6px;width:60%;margin-top:8px;min-height:22px;border:1px solid #ddd;padding:3px;">
                                      {{item.content}}
                                    </div>
                                    <!--对方发的图片-->
                                    <div   v-if="item.type=='1'" @click="seeImg(item)" class="position-relative word-wrap-break-word bg-ffffff  color-666666 border-radius-4" style="margin-left:6px;width:60%;margin-top:8px;min-height:22px;border:1px solid #ddd;padding:3px;">
                                        <img v-lazy="item.content" class="width100">
                                    </div>

                                    <!--对方发的语音-->
                                     <div   v-if="item.type=='2'" class="word-wrap-break-word bg-ffffff  color-666666 border-radius-4" style="margin-left:6px;width:60%;margin-top:8px;min-height:22px;border:1px solid #ddd;padding:3px;">
                                        语音
                                    </div>

                                   </div>  
                                   

                                 
                                    <div v-if="item.sendId==user.id" >
                                     <!--自己发的文字-->
                                    <div   v-if="item.type=='0'"  class="word-wrap-break-word  color-666666 border-radius-4" style="margin-right:6px;width:60%;margin-top:8px;float:right;min-height:22px;border:1px solid #ddd;background:#ddd;padding:3px">
                                        {{item.content}}
                                    </div>

                                    <!--自己发的图片-->
                                    <div   v-if="item.type=='1'" @click="seeImg(item)"  class="position-relative word-wrap-break-word  color-666666 border-radius-4" style="margin-right:6px;width:60%;margin-top:8px;float:right;min-height:22px;border:1px solid #ddd;background:#ddd;padding:3px">
                                       <img v-lazy="item.content" class="width100">
                                    </div>
                                    <!--自己发的语音-->   
                                    <div   v-if="item.type=='2'"  class="word-wrap-break-word  color-666666 border-radius-4" style="margin-right:6px;width:60%;margin-top:8px;float:right;min-height:22px;border:1px solid #ddd;background:#ddd;padding:3px">
                                       <img v-bind:src="item.content">
                                    </div>
                                    </div>

                            </div>
                          <div  class="list-right"  style="">
                              <img   v-if="item.sendId==user.id" class="width100" src="../assets/yonghu.png" style="margin-top:4px;"> 
                              <div  v-if="item.sendId==user.id" class="text-align-center color-888888 font-size-0-6rem">{{user!=''?(user.name).substr(user.name.lnegth-2,user.name.lnegth):''}}</div>
                          </div>
                    </div>
            </div>

            <!--对话框-->
            <div style="height:80px;"></div>
            <div class="position-fixed bg-ffffff" style="width:100%;height:55px;bottom:0;border-top:1px solid #ddd;">
                <!--底部情况1-->
                <div v-if="configDetailsDialogBoxSituation=='1'">
                  <div  class="text-align-center " style="width:12%;height:55px;;float:left;">
                          <img style="width:76%;margin-top:10px;" src="../assets/sound.png">
                  </div>
                          <!--文本编辑-->
                          <div class="display-inline-block DialogBox-textarea">
                                   <!--onpropertychange="this.style.height=this.scrollHeight+'px';"
                                   oninput="this.style.height=30+'px';this.style.height=(this.scrollHeight<110?this.scrollHeight:110)+'px';"
                                  -->
                                  <textarea 
                                  v-model="textareaValue"
                                   v-on:focus="ObtainBottomInputfocus"
                                   v-on:blur="LoseBottomInputfocus"
                                  placeholder=" 输入内容..." class="textarea-div">
                                  </textarea>
                          </div>



                  
                          
                  <div class="position-relative text-align-center" style="width:13%;height:55px;float:right;">
                    <div v-if="textareaValueButtonShow(textareaValue)" @click="SendOutNews()" class="DialogBox-button text-align-center">发送</div>
                    <!--add img-->
                     <img v-if="!textareaValueButtonShow(textareaValue)" @click="ActionSheet()" style="width:76%;margin-top:10px;" src="../assets/add.png">
                  
                  </div>
                  </div>

                  <!--底部情况2-->
                        <div v-if="configDetailsDialogBoxSituation=='2'">
                        <div @click="ActionSheet()"  class="text-align-center " style="width:12%;height:55px;;float:left;">
                                <img style="width:76%;margin-top:10px;" src="../assets/add.png">
                        </div>
                                <!--文本编辑-->
                                <div class="display-inline-block DialogBox-textarea">
                                        <!--onpropertychange="this.style.height=this.scrollHeight+'px';"
                                        oninput="this.style.height=30+'px';this.style.height=(this.scrollHeight<110?this.scrollHeight:110)+'px';"
                                        -->
                                        <textarea 
                                       v-on:focus="ObtainBottomInputfocus"
                                       v-on:blur="LoseBottomInputfocus"
                                        v-model="textareaValue"
                                        placeholder=" 输入内容..." class="textarea-div" >
                                        </textarea>
                                </div>



                        
                                
                        <div class="position-relative text-align-center" style="width:13%;height:55px;float:right;">
                            <div  @click="SendOutNews()" class="DialogBox-button text-align-center">发送</div>
                            
                        </div>
                        </div>

                <!--底部情况3-->
                            <div v-if="configDetailsDialogBoxSituation=='3'">
                            <div   class="text-align-center " style="width:1%;height:55px;;float:left;">
                                 
                            </div>
                                    <!--文本编辑-->
                                    <div class="display-inline-block DialogBox-textarea1">
                                            <!--onpropertychange="this.style.height=this.scrollHeight+'px';"
                                            oninput="this.style.height=30+'px';this.style.height=(this.scrollHeight<110?this.scrollHeight:110)+'px';"
                                            -->
                                            <textarea 
                                            v-model="textareaValue"
                                            
                                            v-on:focus="ObtainBottomInputfocus"
                                            v-on:blur="LoseBottomInputfocus"
                                            placeholder=" 输入内容..." class="textarea-div">
                                            </textarea>
                                    </div>



                            
                                    
                            <div class="position-relative text-align-center" style="width:13%;height:55px;float:right;">
                                <div  @click="SendOutNews()" class="DialogBox-button text-align-center">发送</div>
                                
                            </div>
                            </div>


            </div>
            


               <mt-actionsheet
                    :actions= "actionsData"
                    v-model="actionsSheetVisible">
                </mt-actionsheet>

                <!--popup-->
                <mt-popup
                :visible.sync="popupVisible"
                 v-model="popupVisible"
                popup-transition="popup-fade">
                     <!--人为性显示图-->
               
                <img @click="myCloseOnClickModal()"  v-bind:src="popupSrc" class="position-absolute "  style="width:100%;height:auto;z-index:2001;margin:auto;left:0;top:0;bottom:0;right:0">
                </mt-popup>
               
                
                
                     

  </div>
</template>
</keep-alive>
<script>

import { Header,Lazyload } from 'mint-ui';
import Vue from 'vue';
import http from '../config/http.js';
import config from '../config/config.js';

import { Toast , Indicator ,Actionsheet} from 'mint-ui';


Vue.component(Header.name, Header,Actionsheet.name, Actionsheet,Lazyload);




export default {
  name: 'homeDetailsDialogBox',
  data () {
    return {
      msg: 'home',
      doctorImg:'',
      doctorVal:'',
      doctorName:'',
      scrolldelay:'',//定时器

      
     
      //对话框图片的高度
      DialogBoximgHeight:document.documentElement.clientWidth*0.12,

      ObtainDialogBoxSetIntervalStart:'',//启动定时器
      //对比记录
      DialogBoxValArrLast:'',
     
      //文本框内容
      textareaValue:'',
      //文本框的功能
      configDetailsDialogBoxSituation: config.homeDetailsDialogBoxSituation,

      //对方的信息名字
      ConversationName:(JSON.parse(sessionStorage.getItem("NewNewsArrSessionStorageSign")))?(JSON.parse(sessionStorage.getItem("NewNewsArrSessionStorageSign"))):((JSON.parse(sessionStorage.getItem("homeDetailsVal")))?(JSON.parse(sessionStorage.getItem("homeDetailsVal"))):''),//(JSON.parse(sessionStorage.getItem("homeDetailsVal")))?(JSON.parse(sessionStorage.getItem("homeDetailsVal"))):'',
      //userName
      user:(JSON.parse(localStorage.getItem("loginStorageLocalStorage")))?(JSON.parse(localStorage.getItem("loginStorageLocalStorage"))):'',
      //对话框列表数组
      DialogBoxValArr:[],
      //Action sheet
      actionsData:[
          {name:'拍照',
           method : this.getCamera	// 调用methods中的函数
          },
          {name:'从相册中选择',
           method : this.getCameraImg
          }
          ],
      //Action sheet 显示
      actionsSheetVisible:false,
      //popup
      popupVisible:false,
      //popup img src
      popupSrc:'',
      
      //底部输入框焦点 默认没有获取到
      BottomInputfocus:false,
    }
  },
  mounted(){
         // 取到路由带过来的参数  
         if(this.$route.params.itemObj!=undefined || this.$route.params.itemObj!=null){
                 let routerParams = this.$route.params.itemObj;
                 
                    console.log(routerParams?routerParams:'无'); 
                    this.doctorVal=routerParams;
                    
                    //  console.log('___');
                    //  console.log(this.doctorVal)
                    // console.log('233');
                    //doctorname
                  

                
                    this.doctorName=routerParams.name?routerParams.name:'';
                    //对方头像
                    if(this.doctorVal.photo_url){
                             this.doctorImg= config.ObtainDoctorListDoctorImgSplicing+this.doctorVal.photo_url;
                             //console.log('能获取到数据')
                    }else{
                              //console.log('不能获取到数据')
                                let homeListDoctorArr1Storage=(JSON.parse(sessionStorage.getItem("homeListDoctorArr1")));
                                for(let i in homeListDoctorArr1Storage){
                                   
                                    if((homeListDoctorArr1Storage[i].member_id).toString()==routerParams.id){
                                      
                                        this.doctorImg= config.ObtainDoctorListDoctorImgSplicing+homeListDoctorArr1Storage[i].photo_url;
                                        break;
                                    }
                                }
                              
                    }     
                   

                        //实时刷新历史接口
                         this.ObtainDialogBoxValArrRecord();
                         //启动定时器
                        this.ObtainDialogBoxSetIntervalStart=setInterval(()=>{
                              this.ObtainDialogBoxValArrRecord();
                        },1600)

                          //默认滚动底部
                          setTimeout(()=>{
                                  //document.body.scrollTop =  document.body.scrollHeight;
                                  this.pageScroll();
                          },800);
                        
           } else{
                                    console.log('不是从路由点击跳转过来的');//不是从路由跳转过来的 而是IOS端的后退 直接取本地的储存数据
                                    if(JSON.parse(sessionStorage.getItem("NewNewsArrSessionStorageSign"))){
                                     //从新消息 非点击 用浏览器后退过来
                                     console.log('从新消息');
                                    
                                     if(JSON.parse(sessionStorage.getItem("homeListDoctorArr1"))){
                                             var NewNewsArrSessionStorageSignArr=JSON.parse(sessionStorage.getItem("NewNewsArrSessionStorageSign"));
                                             var homeListDoctorArr1Arr=JSON.parse(sessionStorage.getItem("homeListDoctorArr1"));
                                             for(let x in homeListDoctorArr1Arr){
                                                  if(NewNewsArrSessionStorageSignArr.id==homeListDoctorArr1Arr[x].id){
                                                         var routerParams =homeListDoctorArr1Arr[x];
                                                         break;
                                                  }
                                             }
                                             
                                       console.log(routerParams);      
                                        
                                     }
                                     
                                    }else{
                                     //从医生详情 非点击 用浏览器后退过来
                                      console.log('从医生详情');
                                      var routerParams = JSON.parse(sessionStorage.getItem("homeDetailsVal"));
                                    }
                                   
                                 
                                
                                    console.log(routerParams?routerParams:'无'); 
                                    this.doctorVal=routerParams;
                                    //  console.log('___');
                                    //  console.log(this.doctorVal)
                                    // console.log('233');
                                    //doctorname
                                

                                
                                    this.doctorName=routerParams.name?routerParams.name:'';
                                    //对方头像
                                    if(this.doctorVal.photo_url){
                                            this.doctorImg= config.ObtainDoctorListDoctorImgSplicing+this.doctorVal.photo_url;
                                            //console.log('能获取到数据')
                                    }else{
                                            //console.log('不能获取到数据')
                                                let homeListDoctorArr1Storage=(JSON.parse(sessionStorage.getItem("homeListDoctorArr1")));
                                                for(let i in homeListDoctorArr1Storage){
                                                
                                                    if((homeListDoctorArr1Storage[i].id).toString()==routerParams.id){
                                                    
                                                        this.doctorImg= config.ObtainDoctorListDoctorImgSplicing+homeListDoctorArr1Storage[i].photo_url;
                                                        break;
                                                    }
                                                }
                                            
                                    }     
                                

                                        //实时刷新历史接口
                                        this.ObtainDialogBoxValArrRecord();
                                        //启动定时器
                                        this.ObtainDialogBoxSetIntervalStart=setInterval(()=>{
                                            this.ObtainDialogBoxValArrRecord();
                                        },1600)

                                        //默认滚动底部
                                        setTimeout(()=>{
                                                //document.body.scrollTop =  document.body.scrollHeight;
                                                this.pageScroll();
                                        },800);   
           
           }
                      
              
       
  },
  //（销毁前）
  beforeDestroy(){
      clearInterval(this.ObtainDialogBoxSetIntervalStart);
      clearInterval(this.scrolldelay);
      Indicator.close();
  },
   methods:{
     
      
      goback(){
          this.$router.go(-1);
      },

      ActionSheet(){
            this.actionsSheetVisible=true;
      },

      //拍照
      getCamera(){
            console.log('拍照');
             document.getElementById('inputFileCamera').click();
      },
      //拍照完成事件
       getCameraOnchange(event){
             //alert('拍照Onchange');
             
            // console.log(event.target.files)
            // console.log(document.getElementById('inputFileCamera').files);
                let files=event.target.files;
                //图片小于3MB 才能上传  1MB=1048576字节
                if(files[0].size<3145728){
                var reader =new FileReader();
                reader.readAsDataURL(files[0]);
                var formData= new FormData();
                //formData对象 file 是后端固定的名字
                formData.set("file", event.srcElement.files[0]);
                //把files对象传给接口
                this.imgUpload(formData)
                    
                }else{
                        Toast({
                            message: '图片大小需小于3MB',
                            position: 'bottom',
                            duration: 3000
                        });
                }
           
          
      },

      //相册 
      getCameraImg(){
            console.log('相册');
            document.getElementById('inputFileImage').click();
            
      },
      //相册完成事件
      getCameraImgOnchange(event){
                console.log(event.target.files)
               
                //console.log(document.getElementById('inputFileImage').files);
               let files=event.target.files;
               //let files=document.getElementById('inputFileImage').files;
                //图片小于3MB 才能上传  1MB=1048576字节
                if(files[0].size<3145728){
                var reader =new FileReader();
                reader.readAsDataURL(files[0]);
                var formData= new FormData();
                //formData对象 file 是后端固定的名字
                formData.set("file", event.srcElement.files[0]);
                //把files对象传给接口 
                this.imgUpload(formData)
                    
                }else{
                        Toast({
                            message: '图片大小需小于3MB',
                            position: 'bottom',
                            duration: 3000
                        });
                }
              
            
      },

      //点击图片
      seeImg(item){
            console.log(item);
         
            //用replace 
           //this.$router.replace({ path: '/homeDetailsDialogBoxImgSee',name:'homeDetailsDialogBoxImgSee',params:{itemObj:item}});
        if(config.isIosPlatform==false){

        }else{
          this.popupVisible=true;
          this.popupSrc=item.content;
        }
        
            
      },

      //上传图片
      imgUpload(formData){
              
             Indicator.open();
               http.imgUpload(config.HttpDomain+config.backPhotoUploadFile,formData)
              .then((value)=>{
                  Indicator.close();
                
                 
                  if(value.code=='0'){
                          //图片
                          console.log(value.data.src)
                          this.SendOutNewsImg(value.data.src);
                        
                  }else{  
                          Toast({
                            message: value.error? value.error:'上传图片失败',
                            position: 'center',
                            duration: 2000
                          });

                  }
                  document.getElementById('inputFileCamera').value='';
                  document.getElementById('inputFileImage').value='';
                  
                    setTimeout(()=>{
                          Indicator.close();        
                     },1000);
              },(error)=>{
                  
                  Indicator.close();
                  setTimeout(()=>{
                          Indicator.close();        
                  },1000);
                       Toast({
                      message: '上传图片 失败',
                      position: 'center',
                      duration: 2000
                    });
                  document.getElementById('inputFileCamera').value='';
                  document.getElementById('inputFileImage').value='';
              })
      },

      //关闭
      myCloseOnClickModal(){
           this.popupVisible=false;
      },

      //滚动底部
      getScrollTop(){///滚动条在Y轴上的滚动距离
            　　var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0;
            　　if(document.body){
            　　　　bodyScrollTop = document.body.scrollTop;
            　　}
            　　if(document.documentElement){
            　　　　documentScrollTop = document.documentElement.scrollTop;
            　　}
            　　scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
            　　return scrollTop;
     },
   
      getScrollHeight(){  //文档的总高度
            　　var scrollHeight = 0, bodyScrollHeight = 0, documentScrollHeight = 0;
            　　if(document.body){
            　　　　bodyScrollHeight = document.body.scrollHeight;
            　　}
            　　if(document.documentElement){
            　　　　documentScrollHeight = document.documentElement.scrollHeight;
            　　}
            　　scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
            　　return scrollHeight;
      },
     getWindowHeight(){///浏览器视口的高度
        　　var windowHeight = 0;
        　　if(document.compatMode == "CSS1Compat"){
        　　　　windowHeight = document.documentElement.clientHeight;
        　　}else{
        　　　　windowHeight = document.body.clientHeight;
        　　}
        　　return windowHeight;
        },
      //滚动底部效果
      pageScroll(){ 
             if(this.$route.path=='/homeDetailsDialogBox'){

             
             this.scrolldelay=setInterval(()=>{
                        window.scrollBy(0,22); 
                       
                        // console.log('定时器在执行');
                        // console.log(this.getScrollTop() + this.getWindowHeight())
                        // console.log(this.getScrollHeight())

                         //页面滚动高度 document.body.scrollTop     
                        if(this.getScrollTop() + this.getWindowHeight() >= this.getScrollHeight()){
                            clearInterval(this.scrolldelay)
                        }
             },10)
          
      }
       },   
      //发送按钮的显示与隐藏
      textareaValueButtonShow(str){
          //console.log(str)
          let strText=str.replace(/[ ]/g, "");
          if(strText==''){
               return false;
          }else{
               return true;
          } 
         
      },

      //获取对话框的聊天记录
      ObtainDialogBoxValArrRecord(){
               let DialogBoxValArrRecordObj={
                 toId:this.doctorVal.member_id?this.doctorVal.member_id:this.doctorVal.id,//旧的id  新member_id  toId	String	接收人ID///////////随页面传值变化
                 sendId:this.user.id,//this.user.loginName,//  sendId	String	发送人ID
                 pageNo:'1',//  pageNo	String	当前页数
                 pageSize:'10',//  pageSize	String	每页显示记录数
               }
               http.post(config.HttpDomain+config.communicationGetImByToIdAndSendId,DialogBoxValArrRecordObj)
              .then((value)=>{ 
                  //console.log(value)
                  
                  if(value.message=='1'){
 
                         
                          this.DialogBoxValArr=(value.list).reverse();
                           
                                 if(this.DialogBoxValArrLast!=''){
                                        if(this.DialogBoxValArr[0].createDate==this.DialogBoxValArrLast[0].createDate && 
                                        this.DialogBoxValArr[this.DialogBoxValArr.length-1].createDate==this.DialogBoxValArrLast[this.DialogBoxValArrLast.length-1].createDate
                                        ){
                                            console.log('一样')
                                        }else{
                                            this.DialogBoxValArrLast=this.DialogBoxValArr;
                                            console.log('不一样');
                                            this.pageScroll();
                                        }
                                 }else{
                                         this.DialogBoxValArrLast=this.DialogBoxValArr;
                                 }
                           
                           

                            // console.log(this.DialogBoxValArrLast);
                            // console.log(this.DialogBoxValArr);
                          
                          
                          
                  }else{  

                  }
                  
              },(error)=>{
              
                  
              }) 
      },



      //发送消息=>文本
      SendOutNews(){
              let textareaVal=this.textareaValue.replace(/[ ]/g, "")
              if(textareaVal.length===0){
                      Toast({
                      message: '发送内容不能为空',
                      position: 'center',
                      duration: 2000
                    });
              }else{

              
                 Indicator.open();
               let communicationSendImIbj={
                     toId:this.doctorVal.member_id?this.doctorVal.member_id:this.doctorVal.id,//旧的id  新member_id // toId	String	接收人ID（登录人ID） 
                     toName:this.doctorVal.name, // toName	String	接收人名称
                     sendId:this.user.id,//this.user.loginName, // sendId	String	发送人ID
                     sendName:this.user.name, // sendName	String	发送人名称
                     content:this.textareaValue, // content	String	消息内容 
                     type:'0', // type	String	0:文本消息 1:图片 2:语音 3:视频 4:地理位置 6:文件  
                     sendPicture:'', // sendPicture	String	发送者头像
                     toPicture:'', // toPicture	String	接收者头像
               }
               http.post(config.HttpDomain+config.communicationSendIm,communicationSendImIbj)
              .then((value)=>{
                  Indicator.close();
                  console.log(value)
                  
                  if(value.message=='1'){
                          this.textareaValue='';
                          //  //滚动底部
                          //   setTimeout(()=>{
                          //         document.body.scrollTop =  document.body.scrollHeight;
                          //   },800);
                  }else{  
                          Toast({
                            message: value.error? value.error:'发送失败',
                            position: 'center',
                            duration: 2000
                          });

                  }
                  
              },(error)=>{
                  Indicator.close();
                       Toast({
                      message: '发送失败',
                      position: 'center',
                      duration: 2000
                    });
              })
              
      }     
      },
      //发送消息 图片
      SendOutNewsImg(imgUrl){
               Indicator.open();
               let communicationSendImIbj={
                      toId:this.doctorVal.id,//this.doctorVal.telephone, // toId	String	接收人ID（登录人ID） 
                     toName:this.doctorVal.name, // toName	String	接收人名称
                     sendId:this.user.id,//this.user.loginName, // sendId	String	发送人ID
                     sendName:this.user.name, // sendName	String	发送人名称
                     content:imgUrl, // content	String	消息内容 
                     type:'1', // type	String	0:文本消息 1:图片 2:语音 3:视频 4:地理位置 6:文件  
                     sendPicture:'', // sendPicture	String	发送者头像
                     toPicture:'', // toPicture	String	接收者头像
               }
               http.post(config.HttpDomain+config.communicationSendIm,communicationSendImIbj)
              .then((value)=>{
                  Indicator.close();
                  
                  //console.log(value)
                  
                  if(value.message=='1'){
                          this.textareaValue='';
                          //  //滚动底部
                          //   setTimeout(()=>{
                          //         document.body.scrollTop =  document.body.scrollHeight;
                          //   },800);
                  }else{  
                          Toast({
                            message: value.error? value.error:'图片发送失败',
                            position: 'center',
                            duration: 2000
                          });

                  }
                  
              },(error)=>{
                  Indicator.close();
                       Toast({
                      message: '图片发送失败',
                      position: 'center',
                      duration: 2000
                    });
              })
            
      },
       SpareImg(){
          return 'this.src="' + require('../assets/yisheng.png') + '"';
          
      },
      //获取焦点识别
      ObtainBottomInputfocus(){
                this.BottomInputfocus=true;
                //console.log('获取焦点');
                  setTimeout(()=>{
                          if(this.$route.path=='/homeDetailsDialogBox'){
                                //暂不可用 
                                //document.body.scrollTop =  document.body.scrollHeight;
                          }
                                 
                   },600);
      },
      //失去焦点识别
      LoseBottomInputfocus(){
                this.BottomInputfocus=false;
                //console.log('失去焦点');
      },    
      
      

     
      

     
   }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
    .home-title{
        font-size:19px;
        margin-top:16px;
    }
    .title-left{
        left:6px;
        top:18px;
        
    }
    .title-right{
        right:6px;
        top:18px;
        
    }
    .home-list{
      height:60px;
      border-bottom:1px solid #ddd;
      padding:0 12px;
    }
   

    .list-right{
      width:80%;
    }
    .home-list-img-div{
      height:60px;
      text-align:center;
     
      
    }
    .home-list-img{
        width:50px;
         margin-top:4px;
    }
   .mint-header{
      height:56px;
      background: -webkit-linear-gradient(left, #1de5e2, #b588f7) !important;
      
    }
    .DialogBox-list-margin{
      margin:0 -4px;
    }


    /*list*/
    .list-left{
        width:12%;
        height:50px;
        float:left;
    }
    .list-right{
        width:12%;
        height:50px;
        float:right;
    }

    .DialogBox-button{
       width:90%;
       height:34px;
       margin-top:10px;
       background:#488aff;
       border-radius:6px;
       border:none;
       color:#ffffff;
       font-size:13px;
       line-height:31px;
       box-shadow:0px 1px 3px 0px  #333;
       
    }
    .DialogBox-textarea{
        width:73%;
        height:49px;
        border-bottom:1px solid #ddd;
        margin-left:2px;
        
    } 
     .DialogBox-textarea1{
        width:80%;
        height:49px;
        border-bottom:1px solid #ddd;
        margin-left:2px;
        
    }
    .textarea-div{
        min-width:100%;
        max-width:100%;
        min-height:42px;
        max-height:42px;
        margin-top:7px;
        color:#666666;
        border:none;
    }
    textarea{
      font-size:14px;
      resize: none;
      outline:none
    }
    .transtion{
      transtion:all 0.3s
    }

    .mint-popup{
        width:90%;
    }
</style>
